package com.example.mytest;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;


//首页、启动页
public class Main3Activity extends AppCompatActivity {
    Context context;

    Handler m_myHandler = new Handler();
    int width = BaseApplication.width;  //宽
    int height = BaseApplication.height;    //高
    float density = BaseApplication.density;

    TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);

        context = this;

//        tv = (TextView) findViewById(R.id.tv);
//        tv.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Toast.makeText(context, "已修复2", Toast.LENGTH_SHORT).show();
//
////				Intent intent = new Intent();
////				intent.setClass(context, Main3Activity.class);
////				startActivity(intent);
//            }
//        });
//
//        Toast.makeText(this, "修复"+Tool.show(), Toast.LENGTH_SHORT).show();

//        DisplayMetrics dm = getResources().getDisplayMetrics();
//
//        float value = dm.scaledDensity;
//
//        Log.e("ma3===", value+"==="+width+"==="+height+"==="+density);
//
//
//        TextView tv = findViewById(R.id.tv);
//
//        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
//        params.leftMargin = convertWn(333);
////        params.topMargin = convertHn(260+134)-(int)(200/value);  //260+134-
//        params.topMargin = convertHn(260);
//        tv.setLayoutParams(params);
//
//        tv.setTextSize(convertWn((int)(200/value)));
////        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 150);
////        tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, convertHn(150));
//
//        Typeface typeface= Typeface.createFromAsset(getAssets(), "digital.ttf");
//        tv.setTypeface(typeface);
    }


    //宽度适配
    public int convertWn(int old ) {
//        DisplayMetrics dm = new DisplayMetrics();
//        getWindowManager().getDefaultDisplay().getMetrics(dm);
//        int screenWidth = dm.widthPixels; //1280
//        int screenHeight = dm.heightPixels;////728
        int newx = (old * width) / 1920;
        return newx;
    }

    //    高度适配
    public int convertHn(int old ) {
//        DisplayMetrics dm = new DisplayMetrics();
//        getWindowManager().getDefaultDisplay().getMetrics(dm);
//        int screenWidth = dm.widthPixels; //1280
//        int screenHeight = dm.heightPixels;////728
        int newx = (old * height) / 1080;
        return newx;
    }
}
